/**
 * 
 */
$(document).ready(function() {
		initNoApplyLinksCount()  //初始化未处理链接消息数
		initBloger();
	});

var initBloger=function(){
	$.ajax({
		url : '/bloger/getblogerbyuserid',
		type : 'GET',
		dataType : 'json',
		success : function(data) {
			if(data.code===402){
				window.location.href='/login.html';
			}
			if(data.success){
				$('#mingzi').html(data.bloger.blogerName);
				var zhi = "";
				if(data.bloger.hasPermission == 1){
					zhi = "超级管理员";
				}else{
					zhi = "游客";
				}
				$('#zhicheng').html(zhi);
				var imaStr = '<img alt="images" style="width:64px;height:64px;"class="img-circle" src="' + data.bloger.blogerImage + '" />';
				$('#touxiang').html(imaStr);
			}
		}
	});
}

//退出登录
function logout() {
	delCookie("AuthToken")
	window.location.href="/login.html";
}
function delCookie(name){
	var exp = new Date();
	exp.setTime(exp.getTime() - 1);
	var cval=getCookie(name);
	if(cval!=null){
		document.cookie= name + "="+cval+";expires="+exp.toGMTString();
	}
}
function getCookie(name){
	var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
	if(arr=document.cookie.match(reg)){
		return unescape(arr[2]);
	}else{
		return null;
	}
}
//初始化未处理链接消息数
var initNoApplyLinksCount=function(){
	$.ajax({
		url : '/link/getlinklist',
		type : 'POST',
		data : {
			status : 0,
			isApply : -1,
			pageSize : 999,
			pageIndex : 1
		},
		dataType : 'json',
		success : function(data) {
			if(data.code===402){
				window.location.href='/login.html';
			}
			var count='';
			var isApplyLinks='';
			if(data.success){
				count='<span class="label label-danger pull-right">'+data.count+'</span>';
				isApplyLinks='<span class="label label-danger pull-right">'+data.count+'</span>';
			}else{
				count='<span class="fa arrow"></span>';
			}
			$(".links").append(count);
			$(".isApplyLinks").find('a').append(isApplyLinks);
		},
		error : function() {
		}
	});
} 